# 将models进行序列化

from rest_framework import serializers

from Main import models


# motto序列化器
class MottoSerializer(serializers.ModelSerializer):
    view_count = serializers.SerializerMethodField

    class Meta:
        # 在指定需要序列化的model
        model = models.Motto
        fields = "__all__"


# 文章分类序列化器
class NoteMenuSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.NoteMenu
        fields = [
            'menu_id',
            "menu_code",
            "menu_name",
        ]


# 文章初步信息序列化器
class NoteArticleSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.NoteArticle
        fields = [
            "pk",
            "article_id",
            "menu_code",
            "article_name",
            "article_image",
        ]


# 文章信息序列化器
class ArticleSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.NoteArticle
        fields = [
            "article_name",
            "article_author",
            "article_content",
            "article_create_time",
            "article_update_time",
        ]
